package control;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;

public class ClienteBroker {

	public static void main(String[] args) throws IOException {
			// Construct data
		 	String dest = "3006777825";
	    	String mens = "incluso mas mensajes!";
	    	//String data = "shortcode=1010&password=Antares&destinos=" + dest + "&contenido=" + mens;
	    	
	    	String data = "shortcode=3030&password=tres";
	
		    // Send data
		    URL url = new URL("http://192.168.160.32/broker/brokerRead");
		    URLConnection conn = url.openConnection();
		    conn.setDoOutput(true);
		    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
		    wr.write(data);
		    wr.flush();
	
		    // Get the response
		    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
		    String line;
		    while ((line = rd.readLine()) != null) {
		        System.out.println(line);
		    }
		    wr.close();
		    rd.close();

	}

}
